package demo3;

import java.util.Arrays;
import java.util.Comparator;

public class Test3 {
    public static void main(String[] args) {
        Student student1 = new Student("nana",19,90);
        Student student2 = new Student("qig",10,80);
        AgeComparator  agecomparator = new AgeComparator();
        int ret = agecomparator.compare(student1,student2);
        System.out.println(ret);
    }
}

class Student implements Comparator<Student> {
    public String name;
    public int age;
    public double score;


    public Student(String name, int age, double score) {
        this.name = name;
        this.age = age;
        this.score = score;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", score=" + score +
                '}';
    }

    @Override
    public int compare(Student o1, Student o2) {
        return o1.age - o2.age;
    }
}

class AgeComparator implements Comparator<Student>{

    @Override
    public int compare(Student o1, Student o2) {
        return o1.age - o2.age;
    }
}